package com.zzl.boot.bigevent.controller;

import com.zzl.boot.bigevent.pojo.comment;
import com.zzl.boot.bigevent.pojo.result;
import com.zzl.boot.bigevent.service.commentService;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Validated
@RequestMapping("/comment")
public class commentController {
    @Autowired
    private commentService service;

    //添加评论
    @PostMapping()
    public result addComment(@RequestBody @Validated comment comment) {
        service.add(comment);
        return result.success();
    }
    //删除评论
    @DeleteMapping()
    public result deleteComment(Integer id) {
        service.del(id);
        return result.success();
    }
    //查询评论
    @GetMapping()
    public result<List<comment>> findComment(Integer id) {
        List<comment> list=service.find(id);
        return result.success(list);
    }
    //获取回复评论
    @GetMapping("/reply")
    public result<List<comment>> findReplyComment(Integer id) {
        List<comment> list=service.findReply(id);
        return result.success(list);
    }
    //获取文章评论
    @GetMapping("/arComment")
    public result<List<comment>> findArComment(Integer id) {
        List<comment> list=service.findArComment(id);
        return result.success(list);
    }
}
